-- Copyright The Slam Authors

TRAJECTORY_BUILDER_2D = {
  use_imu_data = true,
  min_range = 0.,
  max_range = 30.,
  min_z = -0.8,
  max_z = 2.,
  missing_data_ray_length = 5.,
  num_accumulated_range_data = 0,
  voxel_filter_size = 0.025,
  min_num_points_in_front = 50,

  adaptive_voxel_filter = {
    max_length = 0.5,
    min_num_points = 200,
    max_range = 50.,
  },

  loop_closure_adaptive_voxel_filter = {
    max_length = 0.9,
    min_num_points = 100,
    max_range = 50.,
  },

  use_online_correlative_scan_matching = true, --false
  real_time_correlative_scan_matcher = {
    linear_search_window = 0.1,
    angular_search_window = math.rad(10.), --math.rad(20.)
    translation_delta_cost_weight = 1.0, --1e-1
    rotation_delta_cost_weight = 1.0, --1e-1
  },

  ceres_scan_matcher = {
    occupied_space_weight = 1000.0, --1.
    translation_weight = 1.0, --10.
    rotation_weight = 1.0, --40.
    ceres_solver_options = {
      use_nonmonotonic_steps = true, --false
      max_num_iterations = 20,
      num_threads = 4, --1
    },
  },

  motion_filter = {
    max_time_seconds = 5.,
    max_distance_meters = 0.2,
    max_angle_radians = math.rad(1.),
  },

  -- TODO(schwoere,wohe): Remove this constant. This is only kept for ROS.
  imu_gravity_time_constant = 10.,
  pose_extrapolator = {
    use_imu_based = false,
    constant_velocity = {
      imu_gravity_time_constant = 10.,
      pose_queue_duration = 0.001,
    },
    imu_based = {
      pose_queue_duration = 5.,
      gravity_constant = 9.806,
      pose_translation_weight = 1.,
      pose_rotation_weight = 1.,
      imu_acceleration_weight = 1.,
      imu_rotation_weight = 1.,
      odometry_translation_weight = 1.,
      odometry_rotation_weight = 1.,
      solver_options = {
        use_nonmonotonic_steps = false;
        max_num_iterations = 10;
        num_threads = 1;
      },
    },
  },

  submaps = {
    num_range_data = 90,
    grid_options_2d = {
      grid_type = "PROBABILITY_GRID",
      resolution = 0.05,
    },
    range_data_inserter = {
      range_data_inserter_type = "PROBABILITY_GRID_INSERTER_2D",
      probability_grid_range_data_inserter = {
        insert_free_space = true,
        hit_probability = 0.7, --0.55
        miss_probability = 0.49,
      },
      tsdf_range_data_inserter = {
        truncation_distance = 0.3,
        maximum_weight = 10.,
        update_free_space = false,
        normal_estimation_options = {
          num_normal_samples = 4,
          sample_radius = 0.5,
        },
        project_sdf_distance_to_scan_normal = true,
        update_weight_range_exponent = 0,
        update_weight_angle_scan_normal_to_ray_kernel_bandwidth = 0.5,
        update_weight_distance_cell_to_hit_kernel_bandwidth = 0.5,
      },
    },
  },

  min_reflector_intensity = 100000,
  max_reflector_intensity = 200000,
  min_reflector_range = 0.1,
  max_reflector_range = 5,
  use_reflector = false,
  reflector_dector = { 
    reflector_type = 0,   -- 0-板，1-柱
    circle_fit_method =  2, -- 0-Null，1-Ransac，2-Least square
    reflector_length = 0.1,
    length_error = 0.02,
    reflector_radius = 0.05, --半径
    radius_error = 0.01,
    min_line_split_dist = 0.05,
    line_outlier_dist = 0.1,
    max_line_gap = 0.1,
    min_reflector_counter_per_cluster = 6,
    match_distance_threshold = 0.2,
    reflector_translation_weight = 1e3,
    reflector_rotation_weight = 0,
    fusion_translation_weight = 1e6,
    fusion_rotation_weight = 1e5,
    new_reflector_min_distance_threshold = 1.0,
  },

}
